<div class="container"> 
	<div class="row"> 
		<div class="panel panel-info">
			<div class="panel-heading">
				<div class="panel-title">My Shopping Cart</div>
			</div>
			<div class="panel-body">
				<table class="table">
					<thead>
						<tr class="active">
							<th width="1"><input type="checkbox" onClick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></th>
							<th width="400">Item</th>
							<th width="300">Period/Quantity</th>
							<th>Price</th>
							<th>Action</th>
						</tr>
					</thead>
					<tbody class="cartcontent">
						<?=$cartcontent?>
					</tbody>
				</table>
				<hr/>
				<div class="text-right">
				<a href="<?php echo base_url('users/checkout');?>" class="btn btn-success">Proceed To Checkout</a>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
function updatecart(rowid,itemid,obj)
{
	price=obj.options[obj.selectedIndex].getAttribute('price');	
	$.ajax({
		url: '<?php echo base_url('enom/updatecart');?>',
		type: 'post',
		data: 'rowid=' + rowid + '&itemid=' + itemid + '&qty=' + obj.value + '&price=' + price ,
		
		beforeSend: function() {
			$(obj).after('<span class="wait">&nbsp;<img src="<?php echo base_url()?>assets/front/img/ajax-loader.gif" alt="" /></span>');
		},		
		complete: function() {
			//$(e).children('.blue').css('background','#F9B014');
			//$(e).children('.blue').children('span').text('checkout');
		},
		success: function(cart) {
			//alert(cart);
			$(".cartcontent").html(cart);
			/*$.get('<?php echo base_url('enom/viewcart');?>', function(cart){
  				$(".cart_content").html(cart);
			});*/
		}
	}); 
}
function addservice(obj)
{
	var totalselecteddomain=$(".cartcontent").find(":checkbox:checked").length;
	if(totalselecteddomain <=0)
	{
		$('#ajax_msg').html('<div class="alert alert-success alert-dismissable flashmsg"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>No domains selected.</div>');
		$('#ajax_msg .flashmsg').delay(5000).fadeOut('slow');
		$('html, body').animate({ scrollTop: 0 }, 'slow'); 
	}
	else
	{
		var val = [];
		$(".cartcontent").find(":checkbox:checked").each(function(i){
		  val[i] = $(this).val();
		});
		
		var productid=$('#service option:selected').val();
		//alert(productid);
		//var ptype=$('#service option:selected').attr('name');
		
		$.ajax({
			url: '<?php echo base_url('enom/addservice');?>',
			type: 'post',
			data: 'prowid=' + val + '&productid=' + productid ,
			dataType:'json',
			
			beforeSend: function() {
				$(obj).after('<span class="wait">&nbsp;<img src="<?php echo base_url()?>assets/front/img/ajax-loader.gif" alt="" /></span>');
				
			},		
			complete: function() {
				//$(e).children('.blue').css('background','#F9B014');
				//$(e).children('.blue').children('span').text('checkout');
			},
			success: function(json) {
				if(json['message'])
				{
					$('#ajax_msg').html('<div class="alert alert-success alert-dismissable flashmsg"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'+ json['message'] + '</div>');
					$('#ajax_msg .flashmsg').delay(5000).fadeOut('slow');
					$('html, body').animate({ scrollTop: 0 }, 'slow'); 
				}
				//$("#service option[value=" + productid+ "]").attr('selected', 'selected');
				$(".cartcontent").html(json['carthtml']);
				
			}
		});
	}
}
function removecart(rowid,itemid,obj)
{
	$.ajax({
		url: '<?php echo base_url('enom/removecart');?>',
		type: 'post',
		data: 'rowid=' + rowid + '&itemid=' + itemid + '&qty=' + obj.value,
		dataType:'json',
		beforeSend: function() {
			$(obj).after('<span class="wait" style="position:absolute">&nbsp;<img src="<?php echo base_url()?>assets/front/img/ajax-loader.gif" alt="" /></span>');
		},		
		complete: function() {
			//$(e).children('.blue').css('background','#F9B014');
			//$(e).children('.blue').children('span').text('checkout');
		},
		success: function(json) {
			if(json['message'])
			{
				$('#ajax_msg').html('<div class="alert alert-success alert-dismissable flashmsg"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'+ json['message'] + '</div>');
				$('#ajax_msg .flashmsg').delay(5000).fadeOut('slow');
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
			}
			//$("#service option[value=" + productid+ "]").attr('selected', 'selected');
			$(".cartcontent").html(json['carthtml']);
		}
	}); 
}
</script>